// import 'package:enjoy_plus_flutter_7/api/home.dart';
import 'package:flutter/material.dart';

// import '../../utils/Request_Dio.dart';
// import '../../utils/toast.dart';

class HomeNotfiyList extends StatefulWidget {
  const HomeNotfiyList({Key? key, required this.notifyList}) : super(key: key);

  final List notifyList;
  @override
  _HomeNotfiyListState createState() => _HomeNotfiyListState();
}

class _HomeNotfiyListState extends State<HomeNotfiyList> {
  Widget getTopWidget() {
    return Row(
      children: [
        Image.asset(
          'assets/images/notice@2x.png',
          width: 20,
        ),
        const Text(
          '社区',
          style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
        ),
        const Text('公告', style: TextStyle(fontSize: 16, color: Colors.orange)),
      ],
    );
  }

  // List notifyList = [
  //   {
  //     'title': '中秋、国庆温馨提示中秋、国庆温馨提示',
  //     'content': '中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示',
  //     'createdAt': '2024-09-22 15:00:00',
  //   },
  //   {
  //     'title': '中秋、国庆温馨提示中秋、国庆温馨提示',
  //     'content': '中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示',
  //     'createdAt': '2024-09-22 15:00:00',
  //   },
  //   {
  //     'title': '中秋、国庆温馨提示中秋、国庆温馨提示',
  //     'content': '中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示',
  //     'createdAt': '2024-09-22 15:00:00',
  //   },
  // ];

  List<Widget> getListView() {
    // List<Widget> children = [];
    return widget.notifyList.map((item) {
      return GestureDetector(
        onTap: () {
          Navigator.pushNamed(context, 'notfiy-detail',
              arguments: {'id': item['id']});
        },
        child: Container(
          margin: const EdgeInsets.only(top: 10),
          padding: const EdgeInsets.all(10),
          decoration: const BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(10)),
              color: Colors.white),
          child:
              Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
            Text(
              item['title'],
              style: const TextStyle(fontWeight: FontWeight.bold),
            ),
            const SizedBox(
              height: 10,
            ),
            Text(item['content']),
            const SizedBox(
              height: 10,
            ),
            Text(item['createdAt']),
          ]),
        ),
      );
    }).toList();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.all(10),
      child: Column(
        children: [
          getTopWidget(),
          ListView(
            shrinkWrap: true,
            physics: const NeverScrollableScrollPhysics(),
            children: getListView(),
          ),
        ],
      ),
    );
  }
}
